<template>
  <icon-park :type="iconType" />
</template>
<script setup>
import { IconPark } from '@icon-park/vue-next/es/all'
import * as IconMap from '@icon-park/vue-next'
import { computed } from 'vue'

const props = defineProps({
  type: {
    type: String,
    default: 'all-application',
  },
})
// 将图标名称统一转成首字母大写的格式
const toPascalCase = (val) => {
  return val.replace(/(^\w|-\w)/g, function (c) {
    return c.slice(-1).toUpperCase()
  })
}
const iconType = computed(() => {
  const PascalCaseName = toPascalCase(props.type)
  return PascalCaseName in IconMap ? props.type : 'all-application'
})
</script>

<style scoped></style>
